<?php
/**@var \Weline\Framework\View\Template $this */
/**@var \Weline\Backend\Block\ThemeConfig $themeConfig */
$themeConfig = \Weline\Framework\Manager\ObjectManager::getInstance(\Weline\Backend\Block\ThemeConfig::class);
?>
<!DOCTYPE html>
<!--
 *@Author       秋枫雁飞
 *@Email        aiweline@qq.com
 *@Forum        https://bbs.aiweline.com
 *@DESC         后台共用头部
-->
<html lang='en' <?= ('rtl' === $themeConfig->getThemeModel()) ? " dir=\"rtl\"" : '' ?>>
<head>
    @template(Weline_Admin::common/head.phtml)
    <!-- jvectormap -->
    <link href="@static(Weline_Admin::assets/libs/jqvmap/jqvmap.min.css)" rel="stylesheet"/>
    <!-- jquery.mCustomScrollbar 插件 -->
    <link href="@static(Weline_Admin::/libs/jquery.mCustomScrollbar/jquery.mCustomScrollbar.css)" rel="stylesheet"/>
    <!-- Sweet Alert-->
    <link href='@static(Weline_Admin::assets/libs/sweetalert2/sweetalert2.min.css)' rel='stylesheet' type='text/css'/>
    <title><?= __('Weline Admin 管理面板') ?></title>
</head>

<body <?= $themeConfig->getLayouts() ?? ''; ?>>

<!--页头工具条 开始-->
@template(Weline_Admin::common/page/loading.phtml)
<!--页头工具条 结束-->

<!-- 开始 页面 -->
<div id="layout-wrapper">


    <!--页头工具条 开始-->
    <w:block class='Weline\Admin\Block\Backend\Page\Topbar'/>
    <!--页头工具条 结束-->

    <!-- ========== Topnav Start ========== -->
    <!--页头菜单栏 开始-->
    <w:block class='Weline\Admin\Block\Backend\Page\Topnav'/>
    <!--页头菜单栏 结束-->

    <!-- ========== Left Sidebar Start ========== -->
    <!--左侧菜单栏 开始-->
    <w:template>Weline_Admin::common/left-sidebar.phtml</w:template>
    <!--左侧菜单栏 结束-->


    <!-- ============================================================== -->
    <!-- Start right Content here -->
    <!-- ============================================================== -->
    <div class="main-content">

        <div class="page-content">
            <div class="container-fluid">

                <!-- start page title -->
                <div class="row">
                    <div class="col-12">
                        <div class="page-title-box d-sm-flex align-items-center justify-content-between">
                            <h4 class="mb-sm-0">
                                <lang>管理员</lang>
                            </h4>

                            <div class="page-title-right">
                                <ol class="breadcrumb m-0">
                                    <li class="breadcrumb-item"><a href="javascript: void(0);">
                                            <lang>系统</lang>
                                        </a></li>
                                    <li class="breadcrumb-item active">
                                        <lang>管理员</lang>
                                    </li>
                                </ol>
                            </div>

                        </div>
                    </div>
                </div>
                <!-- end page title -->
                <!-- start page message -->
                <div class='row'>
                    <template>Weline_Component::message.phtml</template>
                </div> <!-- end message -->
                <div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-body">

                                <h4 class="card-title">
                                    <lang>管理员管理</lang>
                                </h4>
                                <div class="card-title-desc">
                                    <div class='row'>
                                        <div class='col-6'>
                                            <div class="col-md-6">
                                                <block class='Weline\Component\Block\Form\Search' id='acl-search'
                                                       action='*/backend/user/listing'
                                                       method='get'
                                                       keyword='search' value=''
                                                       params=''
                                                       placeholder='请输入搜索词'></block>
                                            </div>
                                        </div>
                                        <div class='col-6'>
                                            <a class='btn btn-primary pull-right mt-1 mb-1'
                                               href="@backend-url('*/backend/user/add')">
                                                <lang>新增</lang>
                                            </a>
                                        </div>
                                    </div>
                                </div>
                                <!--<div class="table-responsive mCustomScrollbar" data-mcs-axis="yx" data-mcs-theme='dark'
                                     style="height: 800px">-->
                                <div class='table-responsive mCustomScrollbar' data-mcs-axis='x'
                                     data-mcs-theme='dark'>
                                    <table class="table table-editable table-nowrap align-middle table-edits">
                                        <thead>
                                        <tr>
                                            <th>ID</th>
                                            <th>
                                                <lang>名称</lang>
                                            </th>
                                            <th>
                                                <lang>邮箱</lang>
                                            </th>
                                            <th>
                                                <lang>头像</lang>
                                            </th>
                                            <th>
                                                <lang>状态</lang>
                                            </th>
                                            <th>
                                                <lang>创建时间</lang>
                                            </th>
                                            <th>
                                                <lang>更新时间</lang>
                                            </th>
                                            <th>
                                                <lang>操作</lang>
                                            </th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <foreach name="users">
                                            <tr data-id='{{v.user_id}}'>
                                                <td data-field='user_id'>{{v.user_id}}</td>
                                                <td data-field='username'>{{v.username}}</td>
                                                <td data-field='email'>{{v.email}}</td>
                                                <td data-field='create_time'>
                                                    <if condition="v.avatar">{{v.avatar}}
                                                        <else/>
                                                        <i class='fas fa-user-shield'></i>
                                                    </if>
                                                </td>
                                                <td data-field='status'>
                                                    <if condition="v.is_deleted === 1">
                                                            <span class="badge bg-danger">
                                                                <lang>已删除</lang>
                                                            </span>
                                                        <else/>
                                                        <if condition="v.is_enabled === 1">
                                                                <span class="badge bg-success">
                                                                    <lang>使用中...</lang>
                                                                </span>
                                                            <else/>
                                                            <span class="badge bg-danger">
                                                                <lang>已禁用</lang>
                                                                </span>
                                                        </if>
                                                    </if>
                                                </td>
                                                <td data-field='create_time'>{{v.create_time}}</td>
                                                <td data-field='update_time'>{{v.update_time}}</td>
                                                <td>
                                                    <if condition="v.user_id !== 1">
                                                        <div class="d-flex gap-2">
                                                            <acl source="Weline_Admin::system_user_delete_post">
                                                                <form action="@backend-url('*/backend/user/delete')"
                                                                      method='post'>
                                                                    <input type='hidden' name='id'
                                                                           value='{{v.user_id}}'>
                                                                    <!--TODO 询问删除 -->
                                                                    <button type='submit'
                                                                            class='btn btn-danger btn-sm ajax-confirm'>
                                                                        <lang>删除</lang>
                                                                    </button>
                                                                </form>
                                                            </acl>
                                                            <acl source="Weline_Admin::system_user_active_post">
                                                                <form action="@backend-url('*/backend/user/active')"
                                                                      method='post'>
                                                                    <input type='hidden' name='id'
                                                                           value='{{v.user_id}}'>
                                                                    <button type='submit'
                                                                            class='btn btn-success btn-sm ajax-confirm'>
                                                                        <lang>激活</lang>
                                                                    </button>
                                                                </form>
                                                            </acl>
                                                            <acl source="Weline_Admin::system_user_inactive_post">
                                                                <form action="@backend-url('*/backend/user/inActive')"
                                                                      method='post'>
                                                                    <input type='hidden' name='id'
                                                                           value='{{v.user_id}}'>
                                                                    <button type='submit'
                                                                            class='btn btn-danger btn-sm ajax-confirm'>
                                                                        <lang>禁用</lang>
                                                                    </button>
                                                                </form>
                                                            </acl>
                                                            <acl source="Weline_Admin::system_user_edit_post">
                                                                <a class='btn btn-info btn-sm'
                                                                   href="@backend-url('*/backend/user/edit')?id={{v.user_id}}">
                                                                    <lang>编辑</lang>
                                                                </a>
                                                            </acl>
                                                        </div>
                                                        <else/>
                                                        <b class="disabled">
                                                            <lang>超级管理员</lang>
                                                        </b>
                                                    </if>
                                                </td>
                                            </tr>
                                        </foreach>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <var>pagination</var>
                    </div> <!-- end col -->
                </div> <!-- end row -->
            </div> <!-- container-fluid -->
        </div>
        <!-- End Page-content -->

        <footer class="footer">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-sm-6">
                        <script>document.write(new Date().getFullYear())</script>
                        © Weline.
                    </div>
                    <div class="col-sm-6">
                        <div class="text-sm-end d-none d-sm-block">
                            Crafted with <i class="mdi mdi-heart text-danger"></i> By <a
                                    href="https://www.aiweline.com/">秋枫雁飞(aiweline)</a>
                        </div>
                    </div>
                </div>
            </div>
        </footer>

    </div>
    <!-- end main content-->

</div>
<!-- END layout-wrapper -->
<!--右边栏-->
@template(Weline_Admin::common/right-sidebar.phtml)

<!-- Table Editable plugin -->
<script src="@static(Weline_Admin::assets/libs/table-edits/build/table-edits.min.js)"></script>
<script src="@static(Weline_Admin::assets/js/pages/menus/table-editable.init.js)"></script>
<script src='@static(Weline_Admin::/libs/jquery.mCustomScrollbar/jquery.mCustomScrollbar.concat.min.js)'></script>
<!-- Sweet Alerts js -->
<script src='@static(Weline_Admin::assets/libs/sweetalert2/sweetalert2.min.js)'></script>

<!-- Sweet alert init js-->
<script src='@static(Weline_Admin::assets/js/pages/menus/sweet-alerts.init.js)'></script>
@template(Weline_Admin::common/footer.phtml)
</body>
</html>
